<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">

    <h:body>
        <div class="section">

            <h:form id="formViewSale">
                <p:growl id="msg" autoUpdate="true" life="3000"/>

                <div class="clearfix">
                    <p:panel id="general_info" header="Dados do Cliente" styleClass="clearfix " >
                        <script>
                            $('html, body').animate({ scrollTop: 0 }, 0);
                        </script>
                        <h:outputLabel value=" " styleClass="grid_4 labelCaption" />

                        <p:outputLabel value="#{managerEditSale.customer.name}" styleClass="grid_14 headerLabel"  />
                        <div class="clear-both"/>

                        <h:outputLabel value="CPF: " styleClass="grid_4 labelCaption" />
                        <h:outputLabel value="#{managerEditSale.customer.cpf}" styleClass="grid_10 labelValue" />
                        <h:outputLabel value="RG: " styleClass="grid_4 labelCaption" />
                        <h:outputLabel value="#{managerEditSale.customer.rg}" styleClass="grid_4 labelValue" />
                        <div class="clear-both"/>

                        <h:outputLabel value="Profissão: " styleClass="grid_4 labelCaption" />
                        <h:outputLabel value="#{managerEditSale.customer.profession}" styleClass="grid_10 labelValue" />
                        <h:outputLabel value="Naturalidade: " styleClass="grid_4 labelCaption" />
                        <h:outputLabel value="#{managerEditSale.customer.nationality}" styleClass="grid_4 labelValue" />
                        <div class="clear-both"/>

                        <h:outputLabel value="Estado Civil: " styleClass="grid_4 labelCaption" />
                        <h:outputLabel value="#{managerEditSale.customer.civilStatus.name}" styleClass="grid_10 labelValue" />
                        <h:outputLabel value="D. Nasc: " styleClass="grid_4 labelCaption" />
                        <h:outputLabel value="#{managerEditSale.customer.dateOfBirth}" styleClass="grid_4 labelValue" >
                            <f:convertDateTime pattern="dd/MM/yyyy"/>  
                        </h:outputLabel>
                        <div class="clear-both"/>

                        <h:outputLabel value="Telefone: " styleClass="grid_4 labelCaption" />
                        <h:outputLabel value="#{managerEditSale.customer.fixedPhone}" styleClass="grid_10 labelValue" />
                        <h:outputLabel value="Celular: " styleClass="grid_4 labelCaption" />
                        <h:outputLabel value="#{managerEditSale.customer.celPhone}" styleClass="grid_4 labelValue" />
                        <div class="clear-both"/>

                        <h:outputLabel value="E-mail: " styleClass="grid_4 labelCaption" />
                        <h:outputLabel value="#{managerEditSale.customer.email}" styleClass="grid_10 labelValue" />
                        <div class="clear"/>

                        <p:dataTable id="tableAddView" var="address" value="#{managerEditSale.customer.addresses}" 
                                     styleClass="grid_24"
                                     rowIndexVar="rowid"
                                     emptyMessage="Nenhum registro">  
                            <f:facet name="header">
                                Endereço
                            </f:facet>
                            <p:column headerText="Rua" width="300">  
                                <h:outputText value="#{address.patio}"/>
                            </p:column>  
                            <p:column headerText="Bairro">  
                                <h:outputText value="#{address.district}"/>
                            </p:column>
                            <p:column headerText="Tipo">  
                                <h:outputText value="#{address.typeAddress}"/>
                            </p:column>
                        </p:dataTable> 

                        <div class="clear"/>
                    </p:panel>
                    <div class="clear"/>

                    <p:panel header="Dados do Lote" styleClass="clearfix ">
                        <h:outputLabel value=" " styleClass="grid_4 labelCaption" />

                        <p:outputLabel value="#{managerEditSale.enterprise.name}" styleClass="grid_14 headerLabel"  />
                        <div class="clear"/>

                        <h:outputLabel value="Quadra: " styleClass="grid_4 labelCaption" />
                        <h:outputLabel value="#{managerEditSale.lot.block}" styleClass="grid_4 labelValue" />
                        <h:outputLabel value="Lote: " styleClass="grid_4 labelCaption" />
                        <h:outputLabel value="#{managerEditSale.lot.num}" styleClass="grid_4 labelValue" />
                        <div class="clear"/>

                        <h:outputLabel value="Nº do Lote: " styleClass="grid_4 labelCaption" />
                        <h:outputLabel value="#{managerEditSale.lot.num}" styleClass="grid_4 labelValue" />
                        <h:outputLabel value="Dimensão: " styleClass="grid_4 labelCaption" />
                        <p:outputLabel value="#{managerEditSale.dimensaoDoLote()}" styleClass="grid_4 labelValue"  />
                        <h:outputLabel value="Área: " styleClass="grid_4 labelCaption" />
                        <h:outputLabel value="#{managerEditSale.lot.area}" styleClass="grid_4 labelValue" />
                        <div class="clear"/>

                        <h:outputLabel value="Tipo: " styleClass="grid_4 labelCaption" />
                        <h:outputLabel value="#{managerEditSale.lot.typeLot.name}" styleClass="grid_4 labelValue" />

                        <div class="clear"/>
                    </p:panel>
                    <div class="clear"/>

                    <p:panel header="Referências" styleClass="clearfix " >
                        <h:outputLabel value="Nome: " styleClass="grid_4 labelCaption" />
                        <h:outputLabel value="#{managerEditSale.sale.nameOfReference1}" styleClass="grid_4 labelValue" />
                        <h:outputLabel value="Telofone: " styleClass="grid_4 labelCaption" />
                        <h:outputLabel value="#{managerEditSale.sale.phoneOfReference1}" styleClass="grid_4 labelValue" />
                        <div class="clear"/>
                        <h:outputLabel value="Nome: " styleClass="grid_4 labelCaption" />
                        <h:outputLabel value="#{managerEditSale.sale.nameOfReference2}" styleClass="grid_4 labelValue" />
                        <h:outputLabel value="Telofone: " styleClass="grid_4 labelCaption" />
                        <h:outputLabel value="#{managerEditSale.sale.phoneOfReference2}" styleClass="grid_4 labelValue" />

                        <div class="clear"/>
                    </p:panel>
                    <div class="clear"/>

                    <p:panel header="Testemunhas" styleClass="clearfix ">
                        <h:outputLabel value="Nome: " styleClass="grid_4 labelCaption" />
                        <h:outputLabel value="#{managerEditSale.sale.nameOfTheWitness1}" styleClass="grid_4 labelValue" />
                        <h:outputLabel value="CPF: " styleClass="grid_4 labelCaption" />
                        <h:outputLabel value="#{managerEditSale.sale.cpfOfTheWitness1}" styleClass="grid_4 labelValue" />
                        <div class="clear"/>
                        <h:outputLabel value="Nome: " styleClass="grid_4 labelCaption" />
                        <h:outputLabel value="#{managerEditSale.sale.nameOfTheWitness2}" styleClass="grid_4 labelValue" />
                        <h:outputLabel value="CPF: " styleClass="grid_4 labelCaption" />
                        <h:outputLabel value="#{managerEditSale.sale.cpfOfTheWitness2}" styleClass="grid_4 labelValue" />

                        <div class="clear"/>
                    </p:panel>

                    <div class="clear"/>

                    <p:panel header="Observações" styleClass="clearfix " >
                        <h:outputLabel value="#{managerEditSale.sale.observation}" styleClass="grid_4 labelValue" />
                        <div class="clear"/>
                    </p:panel>
                    <div class="clear"/>

                    <p:panel header="Corretor" styleClass="clearfix">
                        <h:outputLabel value="Nome: " styleClass="grid_4 labelCaption" />
                        <h:outputLabel value="#{managerEditSale.corrector.name}" styleClass="grid_4 labelValue" />
                        <h:outputLabel value="CPF: " styleClass="grid_4 labelCaption" />
                        <h:outputLabel value="#{managerEditSale.corrector.cpf}" styleClass="grid_4 labelValue" />
                        <div class="clear"/>
                        <h:outputLabel value="CRECI: " styleClass="grid_4 labelCaption" />
                        <h:outputLabel value="#{managerEditSale.corrector.creci}" styleClass="grid_4 labelValue" />
                        <div class="clear"/>
                    </p:panel>
                    <div class="clear"/>

                    <p:panel header="Valores Finais" styleClass="clearfix" >

                        <h:outputLabel value="Forma de Pagamento:" styleClass="grid_4 labelCaption" />
                        <h:outputLabel value="#{managerEditSale.paymentType.name}" styleClass="grid_4 labelValue" />
                        <div class="clear"/>
                        <p:panel styleClass="withoutBorder" visible="#{managerEditSale.paymentType.atSight}">
                            <h:outputLabel value="Valor á vista:" styleClass="grid_4 labelCaption" />
                            <h:outputLabel value="#{managerEditSale.lot.sees}" styleClass="grid_4 labelValue">
                                <f:convertNumber pattern="#,###,##0.00"/>
                            </h:outputLabel>
                            <div class="clear"/>
                            <h:outputLabel value="Desconto de:" styleClass="grid_4 labelCaption" />
                            <h:outputLabel value="#{managerEditSale.discount}" styleClass="labelValue" />
                            <h:outputLabel value="#{managerEditSale.discountType.name}" styleClass="labelValue" />
                            <div class="clear"/>
                            <h:outputLabel value="Valor a pagar:" styleClass="grid_4 labelCaption totalSightingLabel"/>
                            <h:outputLabel value="#{managerEditSale.totalSighting}" styleClass="grid_4 labelValue">
                                <f:convertNumber pattern="#,###,##0.00"/>
                            </h:outputLabel>

                            <div class="clear"/>
                        </p:panel>

                        <p:panel styleClass="withoutBorder" visible="#{managerEditSale.paymentType.installment}">
                            <h:outputLabel value="Valor da Entrada: " styleClass="grid_4 labelCaption"/>
                            <h:outputLabel value="#{managerEditSale.beginValue}" styleClass="grid_4 labelValue" >
                                <f:convertNumber pattern="#,###,##0.00"/>
                            </h:outputLabel>
                            <div class="clear"/>
                            <h:outputLabel value="Parcelado em " styleClass="grid_4 labelCaption" />
                            <h:outputLabel value="#{managerEditSale.valueInterestParcel.interestParcel.qtd} X " styleClass="labelValue" />
                            <h:outputLabel value="#{managerEditSale.valueInterestParcel.value}" styleClass="labelValue">
                                <f:convertNumber pattern="#,###,##0.00"/>
                            </h:outputLabel>

                        </p:panel>

                        <p:panel styleClass="withoutBorder" visible="#{managerEditSale.paymentType.custom}">
                            <h:outputLabel value="Valor da Entrada: " styleClass="grid_4 labelCaption" />
                            <h:outputLabel value="#{managerEditSale.beginValueCustom}" styleClass="grid_4 labelValue">
                                <f:convertNumber pattern="#,###,##0.00"/>
                            </h:outputLabel>
                            <div class="clear"/>
                            <h:outputLabel value="Parcelado em: " styleClass="grid_4 labelCaption" />
                            <h:outputLabel value="#{managerEditSale.qtde} X " styleClass="labelValue" />
                            <h:outputLabel value="#{managerEditSale.parcelValue}" styleClass="labelValue">
                                <f:convertNumber pattern="#,###,##0.00"/>
                            </h:outputLabel>
                            <h:outputLabel value="#{managerEditSale.hasInterest ? ' ( Juros '.concat(managerEditSale.juros).concat(' )') : '' }" styleClass="labelValue" />
                            <div class="clear"/>
                            <h:outputLabel value="Valor Total: " styleClass="grid_4 labelCaption"/>    

                            <h:outputLabel value="#{managerEditSale.totalValueCustom}" styleClass="grid_4 labelValue">
                                <f:convertNumber pattern="#,###,##0.00"/>
                            </h:outputLabel>

                            <div class="clear"/>
                        </p:panel>

                    </p:panel>
                    <div class="buttonAction">
                        <p:commandButton value="Salvar" 
                                         action="#{managerEditSale.save()}"
                                         update="msg"
                                         process="@form"
                                         icon="ui-icon-disk" 
                                         styleClass="ui-priority-primary"/>
                        <p:button href="searchsale.xhtml" value="Cancelar" icon="ui-icon-close"  />
                    </div>
                </div>

            </h:form>
        </div>
    </h:body>
</html>
